Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This pull request introduces a new component-level cache with time-to-live (TTL) support to improve performance when validating API tokens, and updates related tests and dependencies. The cache allows for background refreshing of component data and ensures that expired cache entries are refreshed asynchronously, reducing database load and improving response times. The changes also include dependency upgrades and new environment variable configuration.
Component cache implementation and usage:
Cacheclass insrc/helpers/cache/index.js, including methods for enabling, refreshing, and retrieving cached components with TTL enforcement and background refresh logic.appAuthmiddleware insrc/middleware/auth.jsto leverage the new component cache for token validation, falling back to the database if needed, and refreshing the cache after validation.isTokenValidto encapsulate token validation logic.Configuration and environment:
CACHE_COMPONENT_MSenvironment variable in.env-cmdrc-templateto control the TTL for component cache entries.Testing improvements:
tests/client-api-cached.test.jsto set up the component cache, seed it in test setup, and add comprehensive tests for cache expiry, background refresh, and token renewal scenarios.Dependency upgrades:
sinonto version 22, along with related dependencies@sinonjs/fake-timersanddiffinpackage.jsonandnpm-shrinkwrap.jsonfor improved testing support.electron-to-chromiumto the latest patch version innpm-shrinkwrap.json.